package cn.edu.scau.cmi.detect.controller;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import cn.edu.scau.cmi.ema.domain.Crawlerdetect;
import cn.edu.scau.cmi.ema.domain.Event;
import cn.edu.scau.cmi.ema.domain.base.CmiPagination;
import cn.edu.scau.cmi.front.controller.FrontCmiEmaController;
import cn.edu.scau.cmi.front.domain.FrontCrawlerdetectPagination;
import cn.edu.scau.cmi.front.domain.FrontEventPagination;

@Controller
public class FrontCrawlerdetectController extends FrontCmiEmaController {
	/*
	 * @RequestMapping(value = "/frontListCrawlerdetectGet", method =
	 * RequestMethod.GET) public ModelAndView
	 * frontListCrawlerdetectGet(HttpServletRequest request, @ModelAttribute
	 * FrontEventPagination frontEventPagination) { return
	 * frontListCrawlerdetects(request, frontEventPagination); }
	 */

	@RequestMapping(value = "/frontListCrawlerdetects", method = {RequestMethod.POST, RequestMethod.GET})
	public ModelAndView frontListCrawlerdetects(HttpServletRequest request, @ModelAttribute CmiPagination pagination) {	// TODO Auto-generated method stub
		ModelAndView mav = new ModelAndView();

		pagination = crawlerdetectPaginationService.updatePagination(request, pagination);
		Set<Crawlerdetect> crawlerdetects = crawlerdetectPaginationService.getPaginationCrawlerdetects(pagination);

		mav.addObject("crawlerdetects", crawlerdetects);
		mav.addObject("entityName", "crawlerdetect");
		mav.addObject("pagination", pagination);
		mav.setViewName("frontdetect/crawlerdetect/frontListCrawlerdetects.jsp");
		return mav;
	}
	
	@RequestMapping("/frontViewCrawlerdetect")
	public ModelAndView frontViewCrawlerdetect(@RequestParam Integer crawlerdetectId) {
		ModelAndView mav = new ModelAndView();
		mav.addObject("crawlerdetect", crawlerdetectDAO.findCrawlerdetectByPrimaryKey(crawlerdetectId));
		mav.setViewName("frontdetect/crawlerdetect/frontViewCrawlerdetect.jsp");
		return mav;
	}
}